package com.atguigu.snake;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class Show extends JDialog implements ActionListener 
{
	JTextField a;
	JTextField b;
	JTextField c;
	JButton d;
	Show(JFrame f,String s)
	{
		super(f,s);
		setLayout(new FlowLayout());
		a=new JTextField(10);
		b=new JTextField(10);
		c=new JTextField(10);
		d=new JButton("确定");
		d.addActionListener(this);
		add(new JLabel("请选择背景:背景1,背景2，背景3"));
		add(a);
		add(new JLabel("请选择身体:身体1，身体2，身体3"));
		add(b);
		add(new JLabel("请选择食物：食物1，食物2，食物3"));
		add(c);
		add(d);
		setBounds(60,60,500,500);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	}
	
	public void actionPerformed(ActionEvent e) {
			if(a.getText().equals("背景1"))
			{
				GamePanel.background=Data.background;
			}
			if(a.getText().equals("背景2"))
			{
				GamePanel.background=Data.background1;
			}
			if(a.getText().equals("背景3"))
			{
				GamePanel.background=Data.background2;
			}
			if(b.getText().equals("身体1"))
			{
				GamePanel.body=Data.body;
				GamePanel.head=Data.head;
			}
			if(b.getText().equals("身体2"))
			{
				GamePanel.body=Data.body1;
				GamePanel.head=Data.head1;
			}
			if(b.getText().equals("身体3"))
			{
				GamePanel.body=Data.body2;
				GamePanel.head=Data.head2;
			}
			if(c.getText().equals("食物1"))
			{
				GamePanel.food=Data.food;
			}
			if(c.getText().equals("食物2"))
			{
				GamePanel.food=Data.food1;
			}
			if(c.getText().equals("食物3"))
			{
				GamePanel.food=Data.food2;
			}
			
	}
}
